﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SubstringExtention
{
    public static class ExtentionClass
    {
        public static StringBuilder Substring(this StringBuilder strBuilder,int index, int length)
        {
            StringBuilder result = new StringBuilder();
            if (strBuilder.Length <= index || ((index + length - 1) >= strBuilder.Length))
            {
                throw new IndexOutOfRangeException(String.Format("Index must be between {0}..{1}", 0, strBuilder.Length - 1));
            }
            else
            {
                result.Append(strBuilder.ToString().Substring(index, length));
            }
            return result;
        }
    }
}
